<?php

use Illuminate\Database\Seeder;

class SpotTableSeederder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $user_ids = \App\Model\User::all()->pluck('id')->toArray();

        $secify_ids =  \App\Model\Secify::all()->pluck('id')->toArray();

        $state = [0,1];

        $faker = app(Faker\Generator::class);

        $spot = factory(\App\Model\Spot::class)
            ->times(100)
            ->make()
            ->each(function ($spot)
            use($user_ids,$secify_ids,$state,$faker){
            $spot->uid = $faker->randomElement($user_ids);
            $spot->cid = $faker->randomElement($secify_ids);
            $spot->state = $faker->randomElement($state);
        });
        \App\Model\Spot::insert($spot->toArray());
    }
}
